<template>
  <div class="content_page">
    <div>
      <div class="content_page_circle" v-if="datalist.records.length"> 
      <div class="item" v-for="(i, k) in datalist.records" :key="k">
        <div class="flex_between">
          <div>
            <div  class="title" :style="{ fontSize: globalFont == 'small_font' ? '28rpx' : globalFont == 'small-medium'? '32rpx':'36rpx' }">设备名称：{{ i.equipmentName }}</div>
            <div class="name" :style="{ fontSize: globalFont == 'small_font' ? '28rpx' : globalFont == 'small-medium'? '32rpx':'36rpx' }">设备编号：{{ i.equipmentNo }}</div>
            <div  class="name" :style="{ fontSize: globalFont == 'small_font' ? '28rpx' : globalFont == 'small-medium'? '32rpx':'36rpx' }">设备类型：{{ i.categoryName }}</div>
            <div  class="warnMeg" :style="{ fontSize: globalFont == 'small_font' ? '26rpx' :globalFont == 'small-medium'? '30rpx':'34rpx' }">{{ i.errorMsg }}</div>
          </div>
        </div>
        <div class="data" :style="{ fontSize: globalFont == 'small_font' ? '24rpx' :globalFont == 'small-medium'? '26rpx':'28rpx' }">{{ i.createTime.slice(0, 16) }}</div>
      </div>
    </div>
  <div v-else class="empty-box">
    <image src="/src/static/home/img_None.png"></image>
    <div class="title" :class="['title', globalFont]">暂无数据</div>
  </div>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { ref,getCurrentInstance } from "vue";
import { onLoad } from "@dcloudio/uni-app";
import type { warningInfoType, paramswarningType, resInfo } from "@/api/myInfo/type.ts";
import { warnRecords, handlewarn } from '@/api/myInfo/myInfo.ts'
import { MaintenanceFn } from '@/api/detail/detail.ts' //保养设备
const datalist = ref<warningInfoType>({
  totalNum: "",
  records:[]
});
const formData = ref<paramswarningType>({
  equipmentId: "",
  pageNo: 1,
  pageSize: 10,
  processStatus: 1,
});
const getData = () => {
  warnRecords({
    equipmentId: formData.value.equipmentId?formData.value.equipmentId:'',
    pageNo: formData.value.pageNo,
    pageSize:formData.value.pageSize,
    processStatus:formData.value.processStatus,
  }).then((res: resInfo) => {
    if (res.resultStatus) {
      datalist.value = res.resultData
    } else {
      uni.showToast({
        title: res.errorMessage,
        icon:"none"
      })
    }
  }).catch((err: any) => {
    uni.showToast({
        title: "服务器异常",
        icon:"none"
      })
  })
};
const instance = getCurrentInstance();
const appStorage = instance?.appContext.config.globalProperties.appStorage;
const globalFont = ref()
onLoad((options) => {
  const userInfo_key = appStorage.getObj("userInfo_key");
	globalFont.value = userInfo_key.smallFont
  formData.value.equipmentId = options?.equipmentId
  getData();
});
</script>
<style lang="scss" scoped>
:root {
  /* 默认字号 */
  --font-size-small: 26rpx;
  /* 中号字号 */
  --font-size-medium: 32rpx;
    /* 大号字号 */
  --font-size-large: 40rpx;
}

.small_font {
  font-size: var(--font-size-small);
}

.small-medium {
  font-size: var(--font-size-medium);
}

.small-large {
  font-size: var(--font-size-large);
}
.content_page {
  background: #f8f8f8;

  &_tab {
    width: 100%;
    height: 88rpx;
    padding: 0;
    background-color: #fff;
    display: flex;
    justify-content: space-around;
    border-bottom: 2rpx solid #e8e8e8;
  }

  &_circle {
    width: 100%;
    background-color: #fff;
    box-sizing: border-box;

    .item {
      padding: 32rpx 0;
      background-color: #fff;
      width: 686rpx;
      margin: 0 auto;
      border-bottom: 2rpx solid #e8e8e8;

      .title {
        // font-size: 30rpx;
        color: #333;
        font-weight: bold;
        margin-bottom: 20rpx;
      }

      .warnMeg {
        // font-size: 30rpx;
        color: #333;
        margin-bottom: 15rpx;
        // width: 468rpx
      }
      .name{
        // font-size: 30rpx;
        color: #333;
        margin-bottom: 20rpx;
      }

      .handlebtn {
        width: 172rpx;
        height: 64rpx;
        color: #fff;
        border-radius: 32rpx;
        line-height: 64rpx;
        text-align: center;
      }

      .redbtn {
        background: #c92a2a;
      }

      .greentbn {
        background: linear-gradient(90deg, #00a67e, #006d56);
      }

      .warnNo {
        font-size: 24rpx;
        color: #c92a2a;
        margin-top: 30rpx;
        margin-bottom: 5rpx;
      }

      .data {
        font-size: 24rpx;
        color: #9999;
      }
    }
  }
}
.empty-box {
  height: calc(100vh - 150rpx);
  background: #f8f8f8;
  padding: 32rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  image {
    width: 150rpx;
    height: 150rpx;
    margin-bottom: 40rpx;
  }

  .title {
    // font-size: 32rpx;
    color: #999999;
    font-weight: bold;
  }
}
</style>
